package com.stroke.core;

import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Author: Igor Bubelov
 * Date: 3/6/11 12:47 PM
 */
public class InputHandler implements KeyListener, MouseListener, MouseMotionListener, MouseWheelListener {
    private List<KeyEvent> keyTypedEvents = new ArrayList<KeyEvent>();
    private List<KeyEvent> keyPressedEvents = new ArrayList<KeyEvent>();
    private List<KeyEvent> keyReleasedEvents = new ArrayList<KeyEvent>();

    private List<MouseEvent> mouseClickedEvents = new ArrayList<MouseEvent>();
    private List<MouseEvent> mousePressedEvents = new ArrayList<MouseEvent>();
    private List<MouseEvent> mouseReleasedEvents = new ArrayList<MouseEvent>();
    private List<MouseEvent> mouseEnteredEvents = new ArrayList<MouseEvent>();
    private List<MouseEvent> mouseExitedEvents = new ArrayList<MouseEvent>();

    private List<MouseEvent> mouseDraggedEvents = new ArrayList<MouseEvent>();
    private List<MouseEvent> mouseMovedEvents = new ArrayList<MouseEvent>();

    private List<MouseWheelEvent> mouseWheelMovedEvents = new ArrayList<MouseWheelEvent>();

    public void clearEvents() {
        keyTypedEvents.clear();
        keyPressedEvents.clear();
        keyReleasedEvents.clear();

        mouseClickedEvents.clear();
        mousePressedEvents.clear();
        mouseReleasedEvents.clear();
        mouseEnteredEvents.clear();
        mouseExitedEvents.clear();

        mouseDraggedEvents.clear();
        mouseMovedEvents.clear();

        mouseWheelMovedEvents.clear();
    }

    public void keyTyped(KeyEvent keyEvent) {
        keyTypedEvents.add(keyEvent);
    }

    public List<KeyEvent> getKeyTypedEvents() {
        return keyTypedEvents;
    }

    public void keyPressed(KeyEvent keyEvent) {
        keyPressedEvents.add(keyEvent);
    }

    public List<KeyEvent> getKeyPressedEvents() {
        return keyPressedEvents;
    }

    public void keyReleased(KeyEvent keyEvent) {
        keyReleasedEvents.add(keyEvent);
    }

    public List<KeyEvent> getKeyReleasedEvents() {
        return keyReleasedEvents;
    }

    /////

    public void mouseClicked(MouseEvent mouseEvent) {
        mouseClickedEvents.add(mouseEvent);
    }

    public List<MouseEvent> getMouseClickedEvents() {
        return mouseClickedEvents;
    }

    public void mousePressed(MouseEvent mouseEvent) {
        mousePressedEvents.add(mouseEvent);
    }

    public List<MouseEvent> getMousePressedEvents() {
        return mousePressedEvents;
    }

    public void mouseReleased(MouseEvent mouseEvent) {
        mouseReleasedEvents.add(mouseEvent);
    }

    public List<MouseEvent> getMouseReleasedEvents() {
        return mouseReleasedEvents;
    }

    public void mouseEntered(MouseEvent mouseEvent) {
        mouseEnteredEvents.add(mouseEvent);
    }

    public List<MouseEvent> getMouseEnteredEvents() {
        return mouseEnteredEvents;
    }

    public void mouseExited(MouseEvent mouseEvent) {
        mouseExitedEvents.add(mouseEvent);
    }

    public List<MouseEvent> getMouseExitedEvents() {
        return mouseExitedEvents;
    }

    /////

    public void mouseDragged(MouseEvent mouseEvent) {
        mouseDraggedEvents.add(mouseEvent);
    }

    public List<MouseEvent> getMouseDraggedEvents() {
        return mouseDraggedEvents;
    }

    public void mouseMoved(MouseEvent mouseEvent) {
        mouseMovedEvents.add(mouseEvent);
    }

    public List<MouseEvent> getMouseMovedEvents() {
        return mouseMovedEvents;
    }

    /////

    public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent) {
        mouseWheelMovedEvents.add(mouseWheelEvent);
    }

    public List<MouseWheelEvent> getMouseWheelMovedEvents() {
        return mouseWheelMovedEvents;
    }
}